﻿// See https://aka.ms/new-console-template for more information
// Console.WriteLine("Hello, World!");

//RequestDelegate handler = context => context.Response.WriteAsJsonAsync("Hello, World!");
//WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
//WebApplication app = builder.Build();
//app.Run(handler: handler);
//app.Run();

//var app = WebApplication.Create(args);
//app.Run(handler: HandleAsync);
//app.Run();
//static Task HandleAsync(HttpContext httpContext) => httpContext.Response.WriteAsJsonAsync("Hello, World!");

var app = WebApplication.Create(args);
IApplicationBuilder appBuilder = app;
appBuilder.Use(middleware: HellowMiddleware)
          .Use(middleware: WorldMiddleware);
app.Run();
static RequestDelegate HellowMiddleware(RequestDelegate next)
    => async httpContext =>
    {
        await httpContext.Response.WriteAsync("Hello, ");
        await next(httpContext);
    };

static RequestDelegate WorldMiddleware(RequestDelegate next)
    =>  httpContext =>  httpContext.Response.WriteAsync("World!");
    
